/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.diagnostics;

/**
 * 故障分析的结果。
 *
 * @author Andy Wilkinson
 * @since 1.4.0
 */
public class FailureAnalysis {

	private final String description;

	private final String action;

	private final Throwable cause;

	/**
	 * 创建一个新的 {@code FailureAnalysis}，包含给定的 {@code description} 和
	 * {@code action}（如果有），用户应该采取这些操作来解决问题。
	 * 失败的根本原因是给定的 {@code cause}。
	 * @param description 故障描述
	 * @param action 解决措施
	 * @param cause 故障原因
	 */
	public FailureAnalysis(String description, String action, Throwable cause) {
		this.description = description;
		this.action = action;
		this.cause = cause;
	}

	/**
	 * 返回故障的描述。
	 * @return 故障描述
	 */
	public String getDescription() {
		return this.description;
	}

	/**
	 * 返回为解决故障应采取的措施（如果有）。
	 * @return 解决措施，或 {@code null}
	 */
	public String getAction() {
		return this.action;
	}

	/**
	 * 返回故障的根本原因。
	 * @return 故障原因
	 */
	public Throwable getCause() {
		return this.cause;
	}

}
